﻿<html DIR="LTR" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
  <head>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8" />
    <META NAME="save" CONTENT="history" />
    <title>Connecting and Retrieving Data</title>
    
    <link rel="stylesheet" type="text/css" href="../local/Classic.css">
      
    </link>
    
    <script src="../local/script.js">
      
    </script><script src="../local/script_main.js">&amp;nbsp;</script>
  </head>
  <body>
    <!--Topic built:03/05/2009 21:01:45-->

    
    
    
    
    
    
    
    
    
    <div id="header">
      <table width="100%" id="topTable"><tr>
          <td align="left">
            <span id="headerBold">Connecting and Retrieving Data</span>
          </td>
          <td align="right">
            
          </td>
        </tr></table>
      
      
      
    </div>
    <div id="mainSection">
      
        
        
		<font color="DarkGray"> </font> <p /> <p />
	
        <div id="introductionSection" class="section">
    <p>When you are working with the Microsoft SQL Server JDBC Driver, there are two primary methods for establishing a connection to a SQL Server database. One is to set connection properties in the connection URL, and then call the <b>getConnection</b> method of the <b>DriverManager</b> class to return a <a href="937292a6-1525-423e-a2b2-a18fd34c2893.htm">SQLServerConnection</a> object. </p>
    <div style="margin: .5em 1.5em .5em 1.5em"><b>Note: </b>
      For a list of the connection properties supported by the JDBC driver, see <a href="f1b62700-f046-488d-bd6b-a5cd8fc345b7.htm">Setting the Connection Properties</a>.<p />
    </div>
    <p>The second method involves setting the connection properties by using setter methods of the <a href="097434fd-2b74-411c-a5ed-eba04481dde5.htm">SQLServerDataSource</a> class, and then calling the <a href="a15ee185-f433-4915-9c75-5ebd90c758fd.htm">getConnection</a> method to return a <b>SQLServerConnection</b> object.</p>
    <p>The topics in this section describe the different ways in which you can connect to a SQL Server database, and they also demonstrate different techniques for retrieving data.</p>
  </div><h1 class="heading">In This Section</h1><div id="inThisSectionSection" class="section">
    <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <table width="100%" cellspacing="0" cellpadding="0" border="1" style="background-color: #CCCCCC;" xmlns=""><tr>
            <th>
              Topic
            </th>
            <th>
              Description
            </th>
          </tr><tr>
          <td>
            <p>
              <a href="96fabc42-59d1-4cc0-93c5-db00cbe55e95.htm">Connection URL Sample</a>
            </p>
          </td>
          <td>
            <p>Describes how to use a connection URL to connect to SQL Server and then use an SQL statement to retrieve data.</p>
          </td>
        </tr><tr>
          <td>
            <p>
              <a href="b4a933ee-f2c6-4e0d-a96d-6dd061abf759.htm">Data Source Sample</a>
            </p>
          </td>
          <td>
            <p>Describes how to use a data source to connect to SQL Server and then use a stored procedure to retrieve data.</p>
          </td>
        </tr></table>
    </content>
  </div><span id="seeAlsoSpan"><h1 class="heading">See Also</h1></span><div id="seeAlsoSection" class="section" name="collapseableSection"><a href="e136b87c-a138-45d6-8c3e-bcef94b7e483.htm">Sample JDBC Driver Applications</a><br /><br /></div><!--[if gte IE 5]>
			<tool:tip element="seeAlsoToolTip" avoidmouse="false"/><tool:tip element="languageFilterToolTip" avoidmouse="false"/><tool:tip element="roleInfoSpan" avoidmouse="false"/>
		<![endif]-->
      <div id="footer" class="section">
        
		<hr />
		
		<span id="fb" class="feedbackcss">
			
			
		</span>
		
		<a href="9bad553b-9e70-4696-8499-2e35f772a1e0.htm">
			
			© 2009 Microsoft Corporation. All rights reserved.
		</a>
 	
	
      </div>
    </div>
  </body>
</html>